<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>添加通用工艺</title>
<link rel="stylesheet" type="text/css" href="../../css/style.css"/>
<link rel="stylesheet" type="text/css" href="../../css/form.css" />
<link rel="stylesheet" type="text/css" href="../../css/jquery-ui.css" />
<link rel="stylesheet" href="../../css/jquery.fileupload.css">
<link rel="stylesheet" type="text/css" href="../../css/technologyFselect.css" />
<style type="text/css">
#tablelist tr td label.error{
	left: 54px;
}
#tablelist tr td {
	height:28px;
}
.fileupload{
width: 100px;
}

.fileupload img{
margin-left: 30px;
}
</style>
</head>
<body>
    <!-- 蓝色背景区域 -->
    <div class="wrap">
        <!-- 白色可用区域 -->
        <div class="canuse">
            <!------ 位置 ------>
            <p class="contentText local"><span>位置：基础数据管理 >通用工艺管理> 添加通用工艺</span></p>

            <div class="article_list">
                <!------- 内容 ------->
                <div class="content content1" style="width: 99.6%; margin: 0px auto;">
               		 <input style="display:none;" id="pageFlag" value="addPage">
                    <form id="addForm" action="" method="post">
						<input value='${addFlag}' class="" name = "addFlag" id = "addFlag" style = "display:none;"/>
                        <!-- 用户列表内容区 -->
                        <div class="con con_01">
                            <!-- 表单信息填写区 -->
                            <h4 class="sel_title">
                                <img src="../../img/list/brand1.png" />
                                <span>填写通用工艺信息</span>
                                <span  id="" class="necessary">（带*号为必填项）</span>
                            </h4>
                            <div class="write_area">
                                <table class="contentText" border="1" cellspacing="0" cellpadding="0" width="98%"
                                    style="margin-bottom: 10px;">
                                    <tbody>
                            <tr class="">
                           
							<th class="">通用工艺编号：</th>
							<td >
							<input value='' class="" name = "technologyCode" id = "technologyCode"/>
							<span style='color:red;' id="" class="">*</span>
							</td>
							<th class="">通用工艺名称:</th>
							<td >
							<input value='' class="" name = "technologyName" id = "technologyName"/>
							<span style='color:red;' id="" class="">*</span>
							</td>
							 <th class="">工艺类型：</th>
							<td >
							<select id="technologyTypeId" name="technologyTypeId">
								<option value='-20'>通用</option>
								<option> 测试</option>
							</select><span style='color:red;' id="" class="">*</span>
							</td>
							</tr>
                                        
                            <tr class="">
                            <th class="">通用工艺版本:</th>
							<td >
							<input value='' class="" name = "technologyVersion" id = ""/>
							<span style='color:red;' id="" class="">*</span>
							</td>
							<th class="">备注:</th>
							<td colspan="3" >
							<textarea style="width: -webkit-fill-available;" class="" name = "remark" id = ""></textarea>
							</td>
							</tr>
							<tr class="" style="display:none;">
								<th class="">创建人:</th>
								<td >
									<input value='${userName}' class="" name = "creator" id = ""/>
									<span style='color:red;' id="" class="">*</span>
								</td>
								<th class="">创建日期:</th>
								<td >
									<input value='${productTechnology.createTime}' class="calendar currentTime" name = "createTime" id = "createTime"/>
								</td>
							
							</tr>
							
                                       
                                    </tbody>
                                </table>
                            </div>
                        </div>
                        <!-- 列表展示区 -->
                        <div class="table_border">
                            <div class="show_list">
                                <div class="title_operate">
                                    <h4 class="sel_title">
                                        <img src="../../img/list/brand1.png" /><span>产品工序</span>
                                    </h4>
                                    <div class="operate_area" id="addOperate">
                                        <a id="addDetail" onclick="addDetail()"
                                            class="bgd_add img_hand">增加</a> <a onclick="deleteDetail()" class="bgd_delete img_hand">删除</a>
                                    </div>
                                </div>
                                <div class="list_area">
                                    <!-- 信息列表区 -->
                                    <div class="info_area">
                                        <table id="processTable" class="tablelist" border="1" cellspacing="0" cellpadding="0">
                                            <thead>
                                                <tr class="menuText list_head">
                                                    <th class="checkSelectAll"></th>
                                                    <th class="">序号</th>
                                                    <th class="">工序号</th>
                                                    <th class="">工序名称</th>
                                                    <th class="">工序文件上传</th>
                                                    <th class="">工序文件</th>
                                                    <th class="">备注</th>
                                                    <th class="">下一道工序</th>
                                                </tr>
                                            </thead>
                                            <tbody class="tablelist" id="tablelist">

                                            </tbody>
                                        </table>
                                    </div>
                                    <div align="center" class="btn_sumbit">
				                        <a href="commonTechnology.html" class="bgd_blue_two img_hand contenText">确定</a> 
				                        <a href="commonTechnology.html" class="bgd_white_two img_hand">返回</a>
				                    </div>
                                </div>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
               <!-- 等待加载 -->
			<div id="loader" class="loader hidden">
				<div class="loaderContent">
					<img src="../../img/button/loading.gif"/>
					<p>页面数据加载中，请您耐心等待......</p>
				</div>
			</div>
            
            <!-- 上传文件等待 -->
			<div id="upLoader" class="loader hidden">
				<div class="loaderContent">
					<img src="../../img/button/loading.gif"/>
					<p>上传文件中，请您耐心等待......</p>
				</div>
			</div>
			
		<!-- 鼠标悬浮提示框 -->
		<div id = "promptDiv" class="mask hidden">
			<div class="input_radio">
				<p>上传附件操作</p>
				<div id = "popWindow">
					<button onclick="previewFile();" class="bgd_blue_two img_hand contentText">预览</button>
					<button onclick="downloadFile();" class="bgd_blue_two img_hand contentText">下载</button>
					<button onclick="delFile();" class="bgd_blue_two img_hand contentText">删除</button>
					<button onclick="cancel();" class="bgd_blue_two img_hand contentText">取消</button>
				</div>
			</div>
		</div>
		
		</div>
    <!-- 版尾  -->
    <div class="ending">Copyright© 2018-2019 磐基技术有限公司</div>
    </div>
</body>

<script src="../../js/3rd/jquery-1.9.1.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../../js/3rd/jquery-ui.js" type="text/javascript"></script>
<script src="../../js/3rd/jquery.validate.min.js" type="text/javascript"></script>
<script src="../../js/common/common.js" type="text/javascript" charset="utf-8"></script>
<script src="../..//js/3rd/jquery.ui.widget.js"></script>
<script src="../..//js/3rd/jquery.iframe-transport.js"></script>
<script src="../../js/3rd/jquery.fileupload.js"></script>
<script src="../../js/baseData/commonTeachnologyAdd.js" type="text/javascript"></script>
<script src="../../js/baseData/uploadFileOperate.js" type="text/javascript"></script>
<script src="../../js/baseData/technologyFselect.js" type="text/javascript"></script>
<script type="text/javascript">
$(function(){
	

window.confirm = function confirm(e, callback) {
    jQuery("body").append('<div id="msg_mask"><div id="msg"><div id="msg_top"><img id="msg_img" src="../../img/button/hint1.png" />提示信息<span class="msg_close" id="msg_close">×</span></div><div id="msg_cont">' + e 
    		+ '</div><div class="msg_close msg_btn" id="msg_cancle">取消</div><div class="msg_close msg_btn" id="msg_sure">是</div><div class="msg_close msg_btn" id="msg_no">否</div></div></div>');
    // 确定
    jQuery("#msg_sure").click(function() {
        jQuery("#msg").remove();
        jQuery("#msg_mask").remove();
        if (callback) {
            callback("Y");
        }
    });

    jQuery("#msg_cancle").click(function() {
        jQuery("#msg").remove();
        jQuery("#msg_mask").remove();
        if (callback) {
            callback("C");
        }
    });
    
    jQuery("#msg_no").click(function() {
        jQuery("#msg").remove();
        jQuery("#msg_mask").remove();
        if (callback) {
            callback("N");
        }
    });

    jQuery("#msg_close").click(function() {
        jQuery("#msg").remove();
        jQuery("#msg_mask").remove();
    });
}
});
</script>
<script type="text/javascript">

	var h = document.documentElement.clientHeight;
	$(".wrap").css("height", h);

	// 获取每行 td 的兄弟节点
	$(".info_area td").hover(function() {
		$(this).parent().children().addClass("td_hover");
	}, function() {
		$(this).parent().children().removeClass("td_hover");
	});

	
	// 文件上传的主流程
	function fileUpload(formObj){
		var file = formObj.files[0];
		if (file.size > 524288000){
            alert("最大上传文件不能超过500M");
            return;
        }
		$("#upLoader").show();
		if(file){
			var formData = new FormData();
			formData.append("processfile", file);
			formData.append("coverFlag", "P");
			var uploadResult = ajaxUploadFile(formData);
			// 根据上传结果状态
			if(uploadResult.uploadStatus == "uploadSuccess"){
				uploadFileResultDeal(formObj, uploadResult);
			}else if(uploadResult.uploadStatus == "fileExist"){
				//文件名重复，弹框
				alert("文件名重复请修改文件名后上传！");
				/* window.confirm("文件名重复，是否覆盖?",function(result){
					if("C" != result){
						if("Y" == result){
							formData.set("coverFlag", "Y");
						}else if("N" == result){
							formData.set("coverFlag", "N");
						}
						// 再次上传文件
						var uploadResult = ajaxUploadFile(formData);
						if(uploadResult.uploadStatus == "uploadSuccess"){
							if("Y" != formData.get("coverFlag")){
								
								uploadFileResultDeal(formObj, uploadResult);
							}
						}else{
							alert("文件上传失败！");
						}
					}
				}); */
			}else{
				alert("文件上传失败！");
			}
			
		}
	}
	

	// 上传文件
	function ajaxUploadFile(sendData){
		var uploadResult;
		$.ajax({
			url:"/commonTechnology/uploadFile",
			dataType:"json",
			type:"POST",
			data:sendData,
			async:false,
			cache:false,
			processData:false,
			contentType:false,
			success:function(resultData){
				uploadResult = resultData;
			},
			error:function(resultData){
				uploadResult = "error";
			},
			complete:function(result){
			    $("#upLoader").hide();
			}
		});
		return uploadResult;
	}
	
	// 上传成功后显示对应图标
	function uploadFileResultDeal(targetEle, resultData){
		
		// 显示图片
		var saveFileId = targetEle.getAttribute("id").replace("uploadfile","saveFileName");
		var oriFileId = targetEle.getAttribute("id").replace("uploadfile","oriFileName");
		var saveFileEle = $("#" + saveFileId)[0];
		var oriFileEle = $("#" + oriFileId)[0];
		var oldFileStr = saveFileEle.value;
		if("" != oldFileStr && null != oldFileStr){
			saveFileEle.value = oldFileStr + "," + resultData.saveFileName;
			oriFileEle.value = oriFileEle.value +"," +  resultData.oriFileName;
		}else{
			saveFileEle.value = resultData.saveFileName;
			oriFileEle.value = resultData.oriFileName;
		}
		// class 的第一个数字表示权限文件，第二个表示文件位置是在临时文件夹还是saveFiles
		var imgHtml = "<div onclick = 'operateFile(this)' class = '0 tempUpFiles'><img src='/css/img/fileStandard.png'><span>"+ resultData.oriFileName +"</span></div>";
		$(saveFileEle.parentNode).append(imgHtml);
			
	}
	
	
	

	
</script>
	</html>
